
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>数据查询-舆情模块</title>
  <link rel="stylesheet" href="../../css/element.css">
  <link rel="stylesheet" href="../../css/common.css">
    
    
</head>

<body>
  <div id="app" v-cloak
    v-loading="pageLoading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.8)"
  >
        <div id="mask" v-if="maskShow"></div>
        <el-container style="height: 100%;">


          <el-header>
            <div class="layout-logo">
                <img src="../../images/logo.png" alt="">
            </div>
            <div class="head-nav">
              <a href="../complianceAudit/audit.html" >合规审核</a>
              <a class="active" href="javascript:void(0)">数据查询</a>
              <a href="userList.html" v-if="localStorage.sys_userName==='alex'||localStorage.sys_userName==='zhanggui'">用户列表</a>
            </div>
            <div class="layout-nav font12 user_msg">
                欢迎您，{{userName}}  <a class="red" href="javascript:void(0)" @click="userQuit"> 注销 </a>
            </div>
          </el-header>

          <el-container>
            <!-- common  侧边栏 BEGIN -->
            <el-aside width="220px">

                <el-menu collapse="true">
                  <el-submenu v-for="item in menuData">
                    <template slot="title"><a :href="item.link"><i :class="item.iClass"></i>{{ item.name }}</a></template>
                  </el-submenu>
                </el-menu>

            </el-aside>
            <!-- common  侧边栏 END --> 
            <!-- 右侧主视图部分 BEGIN  -->
            <el-container>

              <!-- content container begin -->
              <el-main>
                <el-card class="main-card">
  
                  <div slot="header" class="clearfix">
                    <span class="font12 gray">当前位置：数据查询 > 舆情模块</span>
                  </div>

                  <div class="input-row">
                    <span class="input-title">查询方式 :</span>
                    <el-radio v-model="selectModel" label="0">股票代码查询</el-radio>
                    <el-radio v-model="selectModel" label="1">行业查询</el-radio>
                  </div>

                  <div class="input-row">

                    <span v-if="selectModel==='0'" class="marR-30">
                      <span class="input-title">请输入要查询的公司代码 :</span>
                      <el-input maxlength=6 size="small" v-model='input_secuCode' class="inline-input"></el-input>
                    </span>

                    <span v-if="selectModel==='1'" class="marR-30">
                      <span class="input-title">行业筛选 :</span>
                      <el-select v-model="input_industryCode" placeholder="请选择" size="small">
                          <el-option
                            v-for="item in industry_info"
                            :key="item.industry_code"
                            :label="item.industry_name"
                            :value="item.industry_code">
                          </el-option>
                        </el-select>
                    </span>

                    <span class="input-title">时间选择 :</span>

                      <el-date-picker
                        v-model="input_startTime"
                        type="datetime"
                        placeholder="选择日期时间"
                        size="small"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        >
                      </el-date-picker>

                      <el-date-picker
                        v-model="input_endTime"
                        type="datetime"
                        placeholder="选择日期时间"
                        size="small"
                        class="marR-30"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        >
                      </el-date-picker>

                      <el-button @click="getQueryResult(selectModel,input_startTime,input_endTime,1,true)" size="small">查询</el-button>
                      <el-button @click="downResult" size="small" v-if="queryResult.length">导出Excel</el-button>

                  </div>

                  

                  

                  <el-table
                    :data="queryResult"
                    v-loading="loading"
                    border
                    stripe
                    style="width: 100%">
                    <el-table-column
                      prop="stock_code"
                      label="公司代码">
                    </el-table-column>
                    <el-table-column
                      prop="company_easy_name"
                      label="公司简称">
                    </el-table-column>
                    <el-table-column
                      prop="industry_name"
                      label="所属行业">
                    </el-table-column>
                    <el-table-column
                      prop="news_title"
                      label="舆情标题"
                      width="300">
                    </el-table-column>
                    <el-table-column
                      prop="news_url"
                      label="舆情正文"
                      width="300">
                    </el-table-column>
                    <el-table-column
                      prop="news_emotion"
                      label="情感度"
                      width="80">
                    </el-table-column>
                    <el-table-column
                      prop="news_src"
                      label="来源">
                    </el-table-column>
                    <el-table-column
                      prop="news_times"
                      label="时间">
                    </el-table-column>
                  </el-table>


                  <el-pagination
                    background
                    layout="prev, pager, next"
                    :total="resultTotal"
                    :current-page=cPage
                    :page-size="50"
                    @current-change="changePage">
                  </el-pagination>
                </el-card>
              </el-main>
              <!-- content container end -->


              <el-footer>
                  <p class="gray">
                    @中国财富传媒集团 版权所有
                  </p>
              </el-footer>

            </el-container>
            <!-- 右侧主视图部分 END  -->
          </el-container>

        </el-container>
    </div>
</body>
    <script src="../../js/vue.js"></script>
    <script src="../../js/element.js"></script>
    <script src="../../js/axios.min.js"></script>
    <script src="../../js/jquery3.3.1.min.js"></script>
    <script src="../../js/md5.js"></script>
    <script src="../../js/common.js"></script>
    <script>
      var app = new Vue({
          el: '#app',
          data(){
            return{
              menuData:Common.DataQueryNav,
              maskShow:false,
              ifCollapse:false,
              userName:localStorage.sys_userName,
              resultTotal:0,
              input_secuCode:'',
              input_industryCode:'000000',
              input_startTime:Common.default_sTime,
              input_endTime:Common.default_eTime,
              industry_info:[],
              queryResult:[],
              selectModel:"0",
              loading: false,
              cPage:1,
              queryUrl:'',
              pageLoading:false
            }
          },
          mounted:function(){//获取行业
             axios
             .get(Common.GET_INDUSTRY_URL)
             .then((res)=>{
               this.industry_info = res.data.data;
             });
          },
          methods:{
              getQueryResult:function(selType,sTime,eTime,pageNum,ifQUery){
                if(ifQUery){
                  $('.el-pager li').removeClass('active').eq(0).addClass('active');
                }
                if(selType==='0'){//证券代码查询
                  if(this.input_secuCode.length!=6){//证券代码非六位
                    this.$message.error('请输入正确的证券代码');
                  }else{
                    this.loading = true;
                    this.queryUrl = `https://goldeye.cfbond.com/cmsys/cms_info/?api_type=opinion&secu_code=${this.input_secuCode}&start_time=${sTime}&end_time=${eTime}&session_id=${localStorage.sys_sessionId}`;
                    axios
                     .get(this.queryUrl+`&page_num=${pageNum}&session_id=${localStorage.sys_sessionId}`)
                     .then((res)=>{
                       this.queryResult = res.data.data.data;
                       this.resultTotal = res.data.data.total_count;
                       this.loading = false;
                     });
                  }

                }else{//行业类别查询
                  if(!this.input_industryCode.length){//未选择分类
                    this.$message.error('请选择正确的行业分类');
                  }else{
                    this.loading = true;
                    this.queryUrl = `https://goldeye.cfbond.com/cmsys/cms_info/?api_type=opinion&first_industry_code=${this.input_industryCode}&start_time=${sTime}&end_time=${eTime}&session_id=${localStorage.sys_sessionId}`;
                    axios
                     .get(this.queryUrl+`&page_num=${pageNum}&session_id=${localStorage.sys_sessionId}`)
                     .then((res)=>{
                       this.queryResult = res.data.data.data;
                       this.resultTotal = res.data.data.total_count;
                       this.loading = false;
                     });
                  }
                }
                
              },
              downResult:function(){
                this.pageLoading = true;
                axios
                .get(this.queryUrl+`&export=1&session_id=${localStorage.sys_sessionId}`)
                .then((res)=>{
                  this.pageLoading = false;
                  Common.newWin(res.data.data);
                })
                .catch((error)=>{
                  this.pageLoading = false;
                  console.log(res);
                });
              },
              changePage:function(cPage){
                this.getQueryResult(this.selectModel,this.input_startTime,this.input_endTime,cPage,false);
              },
              userQuit:function(){
                this.$confirm('确认退出当前账户？', '确认退出', {
                  confirmButtonText: '确定',
                  cancelButtonText: '取消',
                  type: 'warning'
                }).then(()=>{
                    Common.quit();
                  }).catch(()=>{
                    return false;
                  });
              }

          }
      });
    </script>

</html>